/*
               File: NueVeh
        Description: Graba Nuevo Vehiculo
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 28 de Setiembre de 2010 17:21:39.17
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class pnueveh extends GXProcedure
{
   public pnueveh( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( pnueveh.class ), "" );
   }

   public pnueveh( int remoteHandle ,
                   ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( String aP0 ,
                        GxObjectCollection aP1 ,
                        byte[] aP2 )
   {
      execute_int(aP0, aP1, aP2);
   }

   private void execute_int( String aP0 ,
                             GxObjectCollection aP1 ,
                             byte[] aP2 )
   {
      pnueveh.this.AV10Usucod = aP0;
      pnueveh.this.AV8Colecci = aP1;
      pnueveh.this.aP2 = aP2;
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      AV11Mvehco = 0 ;
      /* Using cursor P00102 */
      pr_default.execute(0);
      while ( (pr_default.getStatus(0) != 101) )
      {
         A519MVehCo = P00102_A519MVehCo[0] ;
         AV11Mvehco = A519MVehCo ;
         /* Exit For each command. Update data (if necessary), close cursors & exit. */
         if (true) break;
         /* Check if program is canceled. */
         pr_default.readNext(0);
      }
      pr_default.close(0);
      AV11Mvehco = (short)(AV11Mvehco+1) ;
      AV16GXFIC0 = (short)(1) ;
      while ( ( AV16GXFIC0 <= AV8Colecci.getItemCount() ) )
      {
         AV9Item = ((SdtSDTVehiculo_SDTVehiculoItem)AV8Colecci.item(AV16GXFIC0)) ;
         /*
            INSERT RECORD ON TABLE MMVEH10

         */
         A519MVehCo = AV11Mvehco ;
         A520MVehNr = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnropla() ;
         A521MVehNo = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnompro() ;
         A376TipAut = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Tipautcod() ;
         A385ModCod = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Modcod() ;
         A189MarCod = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Marcod() ;
         A522MVehAn = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehanofab() ;
         A523CmbCod = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Cmbcod() ;
         A525MVehCo = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehcol() ;
         A526MVehNr = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnromot() ;
         A527MVehNr = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnroser() ;
         A528MVehNr = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnrocil() ;
         A529MVehPe = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehpessec() ;
         A530MVehPe = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehpesbru() ;
         A531MVehCa = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehcaruti() ;
         A532MVehLo = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehlon() ;
         A533MVehAl = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehalt() ;
         A534MVehAn = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehanc() ;
         A535MVehNr = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnroeje() ;
         A536MVehNr = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnrorue() ;
         A537MVehNr = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnroasi() ;
         A538MVehNr = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnropue() ;
         A539CmbCod = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Cmbcodcnv() ;
         A540MVehCa = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehcar() ;
         A541MVehCa = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehcarcnv() ;
         A542MVehCo = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehcolcnv() ;
         A543MVehNM = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnmocnv() ;
         A544MVehNs = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnsecnv() ;
         A545MVehNC = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehncicnv() ;
         A546MVehPS = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehpsecnv() ;
         A547MVehCU = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehcutlcnv() ;
         A548MVehLo = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehloncnv() ;
         A549MVehAl = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehaltcnv() ;
         A550MVehNe = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnejcnv() ;
         A551MVehNR = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnrucnv() ;
         A552MVehNA = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnascnv() ;
         A553MVehNP = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehnpucnv() ;
         A593MVehCo = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehcodcnv() ;
         A594MVehPB = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehpbrcnv() ;
         A595MVehAn = AV9Item.getgxTv_SdtSDTVehiculo_SDTVehiculoItem_Mvehanccnv() ;
         A597MVehEs = "1" ;
         A586MVehFC = GXutil.serverDate( context, remoteHandle, "DEFAULT") ;
         A587MVehHC = GXutil.serverTime( context, remoteHandle, "DEFAULT") ;
         A588MVehUC = AV10Usucod ;
         /* Using cursor P00103 */
         pr_default.execute(1, new Object[] {new Short(A519MVehCo), A520MVehNr, A521MVehNo, new Byte(A376TipAut), A385ModCod, new Short(A522MVehAn), new Integer(A523CmbCod), A525MVehCo, A526MVehNr, A527MVehNr, new Integer(A528MVehNr), new Integer(A529MVehPe), new Integer(A530MVehPe), new Integer(A531MVehCa), new Integer(A532MVehLo), new Integer(A533MVehAl), new Integer(A534MVehAn), new Integer(A535MVehNr), new Integer(A536MVehNr), new Integer(A537MVehNr), new Integer(A538MVehNr), new Integer(A539CmbCod), A540MVehCa, A541MVehCa, A542MVehCo, A543MVehNM, A544MVehNs, new Integer(A545MVehNC), new Integer(A546MVehPS), new Integer(A547MVehCU), new Integer(A548MVehLo), new Integer(A549MVehAl), new Integer(A550MVehNe), new Integer(A551MVehNR), new Integer(A552MVehNA), new Integer(A553MVehNP), A586MVehFC, A587MVehHC, A588MVehUC, new Long(A593MVehCo), new Integer(A594MVehPB), new Integer(A595MVehAn), A597MVehEs, A189MarCod});
         if ( (pr_default.getStatus(1) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
            AV12Pout = (byte)(1) ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         /* End Insert */
         AV16GXFIC0 = (short)(AV16GXFIC0+1) ;
      }
      cleanup();
   }

   protected void cleanup( )
   {
      this.aP2[0] = pnueveh.this.AV12Pout;
      Application.commit(context, remoteHandle, "DEFAULT", "pnueveh");
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      AV12Pout = 0 ;
      AV11Mvehco = 0 ;
      P00102_A519MVehCo = new short[1] ;
      A519MVehCo = 0 ;
      AV16GXFIC0 = 0 ;
      AV9Item = new SdtSDTVehiculo_SDTVehiculoItem(context);
      GX_INS48 = 0 ;
      A520MVehNr = "" ;
      A521MVehNo = "" ;
      A376TipAut = 0 ;
      A385ModCod = "" ;
      A189MarCod = "" ;
      A522MVehAn = 0 ;
      A523CmbCod = 0 ;
      A525MVehCo = "" ;
      A526MVehNr = "" ;
      A527MVehNr = "" ;
      A528MVehNr = 0 ;
      A529MVehPe = 0 ;
      A530MVehPe = 0 ;
      A531MVehCa = 0 ;
      A532MVehLo = 0 ;
      A533MVehAl = 0 ;
      A534MVehAn = 0 ;
      A535MVehNr = 0 ;
      A536MVehNr = 0 ;
      A537MVehNr = 0 ;
      A538MVehNr = 0 ;
      A539CmbCod = 0 ;
      A540MVehCa = "" ;
      A541MVehCa = "" ;
      A542MVehCo = "" ;
      A543MVehNM = "" ;
      A544MVehNs = "" ;
      A545MVehNC = 0 ;
      A546MVehPS = 0 ;
      A547MVehCU = 0 ;
      A548MVehLo = 0 ;
      A549MVehAl = 0 ;
      A550MVehNe = 0 ;
      A551MVehNR = 0 ;
      A552MVehNA = 0 ;
      A553MVehNP = 0 ;
      A593MVehCo = 0 ;
      A594MVehPB = 0 ;
      A595MVehAn = 0 ;
      A597MVehEs = "" ;
      A586MVehFC = GXutil.nullDate() ;
      A587MVehHC = "" ;
      A588MVehUC = "" ;
      Gx_err = 0 ;
      Gx_emsg = "" ;
      pr_default = new DataStoreProvider(context, remoteHandle, new pnueveh__default(),
         new Object[] {
             new Object[] {
            P00102_A519MVehCo
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private byte AV12Pout ;
   private byte A376TipAut ;
   private short AV11Mvehco ;
   private short A519MVehCo ;
   private short AV16GXFIC0 ;
   private short A522MVehAn ;
   private short Gx_err ;
   private int GX_INS48 ;
   private int A523CmbCod ;
   private int A528MVehNr ;
   private int A529MVehPe ;
   private int A530MVehPe ;
   private int A531MVehCa ;
   private int A532MVehLo ;
   private int A533MVehAl ;
   private int A534MVehAn ;
   private int A535MVehNr ;
   private int A536MVehNr ;
   private int A537MVehNr ;
   private int A538MVehNr ;
   private int A539CmbCod ;
   private int A545MVehNC ;
   private int A546MVehPS ;
   private int A547MVehCU ;
   private int A548MVehLo ;
   private int A549MVehAl ;
   private int A550MVehNe ;
   private int A551MVehNR ;
   private int A552MVehNA ;
   private int A553MVehNP ;
   private int A594MVehPB ;
   private int A595MVehAn ;
   private long A593MVehCo ;
   private String AV10Usucod ;
   private String A520MVehNr ;
   private String A521MVehNo ;
   private String A385ModCod ;
   private String A189MarCod ;
   private String A525MVehCo ;
   private String A526MVehNr ;
   private String A527MVehNr ;
   private String A540MVehCa ;
   private String A541MVehCa ;
   private String A542MVehCo ;
   private String A543MVehNM ;
   private String A544MVehNs ;
   private String A597MVehEs ;
   private String A587MVehHC ;
   private String A588MVehUC ;
   private String Gx_emsg ;
   private java.util.Date A586MVehFC ;
   private byte[] aP2 ;
   private IDataStoreProvider pr_default ;
   private short[] P00102_A519MVehCo ;
   private GxObjectCollection AV8Colecci ;
   private SdtSDTVehiculo_SDTVehiculoItem AV9Item ;
}

final class pnueveh__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("P00102", "SELECT [MVehCod] FROM [MMVEH10] WITH (NOLOCK) ORDER BY [MVehCod] DESC ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("P00103", "INSERT INTO [MMVEH10] ([MVehCod], [MVehNroPla], [MVehNomPro], [TipAutCod], [ModCod], [MVehAnoFab], [CmbCod], [MVehCol], [MVehNroMot], [MVehNroSer], [MVehNroCil], [MVehPesSec], [MVehPesBru], [MVehCarUti], [MVehLon], [MVehAlt], [MVehAnc], [MVehNroEje], [MVehNroRue], [MVehNroAsi], [MVehNroPue], [CmbCodCnv], [MVehCar], [MVehCarCnv], [MVehColCnv], [MVehNMoCnv], [MVehNseCnv], [MVehNCiCnv], [MVehPSeCnv], [MVehCUtlCn], [MVehLonCnv], [MVehAltCnv], [MVehNejCnv], [MVehNRuCnv], [MVehNAsCnv], [MVehNPuCnv], [MVehFCR], [MVehHCR], [MVehUCR], [MVehCodCnv], [MVehPBrCnv], [MVehAncCnv], [MVehEst], [MarCod], [MVehFUM], [MVehHUM], [MVehUUM]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, convert( DATETIME, '17530101', 112 ), ' ', ' ')", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((short[]) buf[0])[0] = rslt.getShort(1) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 1 :
               stmt.setShort(1, ((Short) parms[0]).shortValue());
               stmt.setString(2, (String)parms[1], 20);
               stmt.setString(3, (String)parms[2], 50);
               stmt.setByte(4, ((Byte) parms[3]).byteValue());
               stmt.setString(5, (String)parms[4], 10);
               stmt.setShort(6, ((Short) parms[5]).shortValue());
               stmt.setInt(7, ((Integer) parms[6]).intValue());
               stmt.setString(8, (String)parms[7], 50);
               stmt.setString(9, (String)parms[8], 50);
               stmt.setString(10, (String)parms[9], 50);
               stmt.setInt(11, ((Integer) parms[10]).intValue());
               stmt.setInt(12, ((Integer) parms[11]).intValue());
               stmt.setInt(13, ((Integer) parms[12]).intValue());
               stmt.setInt(14, ((Integer) parms[13]).intValue());
               stmt.setInt(15, ((Integer) parms[14]).intValue());
               stmt.setInt(16, ((Integer) parms[15]).intValue());
               stmt.setInt(17, ((Integer) parms[16]).intValue());
               stmt.setInt(18, ((Integer) parms[17]).intValue());
               stmt.setInt(19, ((Integer) parms[18]).intValue());
               stmt.setInt(20, ((Integer) parms[19]).intValue());
               stmt.setInt(21, ((Integer) parms[20]).intValue());
               stmt.setInt(22, ((Integer) parms[21]).intValue());
               stmt.setString(23, (String)parms[22], 50);
               stmt.setString(24, (String)parms[23], 50);
               stmt.setString(25, (String)parms[24], 50);
               stmt.setString(26, (String)parms[25], 50);
               stmt.setString(27, (String)parms[26], 50);
               stmt.setInt(28, ((Integer) parms[27]).intValue());
               stmt.setInt(29, ((Integer) parms[28]).intValue());
               stmt.setInt(30, ((Integer) parms[29]).intValue());
               stmt.setInt(31, ((Integer) parms[30]).intValue());
               stmt.setInt(32, ((Integer) parms[31]).intValue());
               stmt.setInt(33, ((Integer) parms[32]).intValue());
               stmt.setInt(34, ((Integer) parms[33]).intValue());
               stmt.setInt(35, ((Integer) parms[34]).intValue());
               stmt.setInt(36, ((Integer) parms[35]).intValue());
               stmt.setDate(37, (java.util.Date)parms[36]);
               stmt.setString(38, (String)parms[37], 8);
               stmt.setString(39, (String)parms[38], 10);
               stmt.setLong(40, ((Long) parms[39]).longValue());
               stmt.setInt(41, ((Integer) parms[40]).intValue());
               stmt.setInt(42, ((Integer) parms[41]).intValue());
               stmt.setString(43, (String)parms[42], 1);
               stmt.setString(44, (String)parms[43], 10);
               break;
      }
   }

}

